<?php
/** @var Router $router */

use app\middleware\Group;
use app\middleware\Route;
use core\Request;
use core\Response;
use core\Router;

$router->get('/', function(Request $request, Response $response) {
    $response->text("from /");
});

$router->get('/test', function(Request $request, Response $response) {
    $response->text("from /test");
});

$router->get('/test2', function(Request $request, Response $response) {
    $response->text("from /test2");
});
$router->group('group', function(Router $router) {
    $router->get('', function(Request $request, Response $response) {
        $response->text('from /group');
    });

    $router->get('test', function(Request $request, Response $response) {
        $response->text('from /group/test');
    });
});

$router->get('/name/:name/age/:age', function(Request $request, Response $response) {
    $response->json($request->getParams());
});

$router->group('user', function(Router $router) {
    $router->namespace('app\api');
    $router->middleware(Group::class);
    $router->get('login', 'UserController@login', Route::class);
    $router->get('logout', 'UserController@logout');
});
